package pay;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;


import pay.ddd.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import JavaUtils.CSUtils.Log.CLog;
import org.eclipse.jetty.util.UrlEncoded;



public class ChargeCall {
    static final String tag = "ChargeCall";
    private final static String wx_appid = "wx883c2ae14b92262f";
    private final static String wx_mchid = "1601286514";//商户id
    private static String wx_notify_url = "/wxpaycall";
    private final String url = "https://api.mch.weixin.qq.com/v3/pay/transactions/app";
    private final String privatekey = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDQ38Bdy8q2hElX56hj/EAlOnIPSGJvfqG5eV35oa9T3gmZItywJc+cFNtVL9DXEv2gua+Usm5klyAJKAgH0SYtMbVOV9V1G/WCoE0UHqo+pDv4EKeA0wF7v9witFwHG/y1HXgDTpMWbb5PSI/GmWLddfQyIRCs8khRKq4oqlfMyEEiz+6JhS+7jEwh6ZC7VTYIhJuXEF00NGD0yiPNjY2jYsAQqH9XL/lIZ08ewP0XqtgpMIzAsjQc8mmwBMXPitPIAdrKfnWdn+IC5EYrcq0adi7tKPZIp3IZtdMXGtmF8maW7LNvO3OjnlE/Kp3FTXY/vL3LG3EYKSqFr+2d8cSPAgMBAAECggEAH2FeTzkszVr2geRl4g+lu3IabL1dPI7z0R+wxK5L3ve+zWj1auljVXm0sgmrAITz4c/D1z0vZKFnyLhg7Hu5lpSfPpPnl96JdgSLT/iDb0HRWKV35NzOnj7m3bfnE5Ja1wMEYsrNQlNegh7OqvGkbs0n0Ngy3yjPQJJ+89ETu8ocf0tgQlaDRm+R9Vxzr+OiTM6BxPBZNOOQYU6CeSMOzgRdlZUxXTfBZDn5qWa/23N/ET/YfjqEGTtm8pr0drzUL36khrfOPNxyjCxjgHUQIzTqP0dK2Zs/V2Vlm3aydkHzI/jy/6Fy/cDTZx4mXkddzMiwz+1PN8J3bIZYxmEbgQKBgQD5rwo3TpOHv1fwwGqnDCrx78CSRxvzLAc556E4bbsEgNv/nFIBhpvzmPHtNxdUCcMoop1PHWesirqewEazAMJkHdOtDn9/hyGigVz3gTKAH5zkc3KFGRD9xV46FxNoFOecwYW8J5ANZAOvDU/lN2ccK8t0Z8bC/AdkhQlMqLMWYQKBgQDWKG0rgvHtHyCIziqyPhS7lUlnSs24x+9yU3EaLyluOPXV+++OpwAdtdGv0X/sSUE3ski69TfaT54telPBidkoDR3MP9yDC3N/0JjxqmRaUUx8prSRF00BLtSU3qL6wDqKclacyJFiAU/Ti4Px5ml+8UwXMPBXPaDvyRFnlQvg7wKBgFY7N8IGJzmYwdxp9+udbi+EZ/OdD3AaYpyC/NEqRI63mkNbT48rWCz3Q4ZzomDpxjcAgmfSdf3HI9C0AzbLKle9XV/FRA9dMiaXmu339uL9CAh2PrTtBUs/oN1bHt6xaZRf2bozx7J4OjV42YEGc1vtXCTlumWY+UykDaQmF0PBAoGAVljGa5zIXosGWyKFJIjTYy62AeevOqmiab4rBBuv4LkmpbiGxkWfTltYyEL4CRUgLoy7tmXYtzUS2dNQoeAqpnNjaE73Yf7j+szoXcgN3jyZUkkE1NtIOQngvIVnwSJweBHRyjU0KQfOX8UI1ifIsV4pB9C7lvFKSmQPmGwH9hECgYAy9NlS3tKme2Y5ITpvu8IAImspoZq5kreKvaZ9kGQIlK6ycUn/fTT+IxNrmbxWNLyEhHBs+mzWx+6vfe8vs5PfayXfBpkpZ/CmRisEnyJa2kBTzIhuxFzMeXkHlicnxIkMd5hPDNsfSlp9Aqhf1JZSZybuNVdIULccn60+JqxeGg==";
//	private static String key = "vjlMoLQWRDVLBkb26fyYSknxS5RpOtqP";// 支付的key 在微信商户平台-->账户设置--->api-->密钥设置
    // f1de9d97be334593ae2e2438ab0ffcd5


    Packet packet;

    private final String zfb_appid = "2021002111603593";// 支付宝appid;
    private final String zfb_method = "alipay.trade.app.pay";// 接口名称
    private final String zfb_h5method = "alipay.trade.wap.pay";// H5 接口
    private final String zfb_nativemethod = "alipay.trade.precreate";// 二维码接口
    private final String charset = "utf-8";

    private final String sign_type = "RSA2";// 签名参数

    private final String version = "1.0";// 版本
    private final String notify_url = "/Alipaycallback";// 通知url
    private final String ali_notify_url = "/AliPayQrCall"; //二维码通知的 的url
    /**
     * 下单私钥
     */
    private final static String alikey = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCSGv5febFKnVzEFZNoPEDGHLb4/+nK+qc1Gg5AoTZZW/L++7ca4t2+7Zgzw4A0vMpTq8lvnpwzRLLdXTbn1wqKsmXm/0Zvb3IStxSm8kfumXW/EZ49vfb2DyXa9N3IBg94YT2HI3KmwNmkxsPSqCMyJnnHy3qvsQTstNQ483/9SvYmKd7zEzngkGK1G9oD94/yMGPw9HjoPjsjjcljouzh8p+dyDVdrEgibx4nv7et99PpNGpbIIpaZge2x1R6D/Iz3wkbm5JAN353M2srofMzwpvwXF6mNCCanom/Y1wYPQbzk5on4qxKwQo1Q9OXuTCBM6luxLRQcKkeefhI68zfAgMBAAECggEAAKTv1Dn0JzEUdKTntoD1hCoiQGzYehWq4RgRUgWj+LboFmnDv/GaKrpffnLxQMpIViAezkgzxiIaa9F6aYFQQZZRzrf3doxWQ3DdPXM6D/pLQ6FvQjRxP1qHvzRvOe+U5+H95HeqjMOy8gASYv5s0U7MIK5sBxRPwj915B5mxRYq0Smt4r/K1K/adrvKqct15UlL3pCKtej6RSjpZDK0+CrF+nyQtlKpD7qaRYz4+u3KMMvjw3AbeTCKN8hMpkAHu7qZFAZ30/CSRVwolI8OYUq6N+T0K1t4peF7pFQ/S3woOSoFM0YODffZxTXXe/WuVHomjMNO8dYhDJBysp1DWQKBgQDc/+xdch0AppAjYJ2TsME8lIvEewA/tizqq2S1YaBDftVvhUZfOvswculfg4C1m1tk27zXbt+5r9K7uitV4hgmftV3maq7msasG8D4MgZM3y6DXE0h/FXKQVqMUzJNy0ngA7JdRxu3aHvPwLAuED+QkOZgjSldFu1uytK6et4nywKBgQCpPpp5JuThG0b6mj8HzHV+G+w8X3HD3jELQRQ3V9jhThUWLUj35T2Yq2QVUMNo6hFBW1j11/51Kh7k8mg8HR+sCAKnGdEUSrvt4NMOPiM7uXdMSmJybC4OSTR31NDV2IIGw1+WFbMtjjO+YzQ/1iqH4bQD3U2l7wn5DFkOzTPEvQKBgEup+50Kws9EN7lFDO5R5/b7zNaaXj1x+/Lkd3h6UkqJlD24XZ2hLfsqfKhM97Y12JaxfPgtZ7/FaNsJJGklHaugZSmrnP7aQQcQAYN4bRvIlb43zdjC8gRrV7sPiPuFjGd8HIc/H0guJ6W7jRZYTcsLMTUBX5YVkXkLTBa4lnL9AoGBAKTctt0NZidhyuKTHpMaN9mAmb61urxx1JSB8I94o2vWA/R2aH4ScM4nJncdFT09xVFFCoNwxA6d2TpsZ90nAZMyumLMYz7BDg/K0c0t+mRTZkKKsxuDBdoktVeFl2i4XvD3oEUzHjdiLkVnnZ4RoZx74D9jdCAPmkdgH+CrQ6KBAoGAHBNAYwXSZrUosQU8LWqnkq8BfvNCC560lmSJAOAt6dSK7XsNnyGL2fjEE6c/akAGWsY3TQVSCQFfZdUw4dAGX0Az2dak/hHCyLCljuntPM9RrTgvyrk7Enlb5txEFY83pk5DoKy5Cgvf4FsqtiCtX0OYkD+Nph+n3j9qtUuGmXE=";


    //@Override
    public void run() {
        long time = System.currentTimeMillis();

        RolePayReq req = new RolePayReq();
        int chargeid = req.chargeid;
        int version = req.version;
        String channelCode = req.channelCode;
        Player player = null;//(Player) session.getClient();
        if (player == null) {
            //Player.sendError(session, D._T(D.player_0001));
            return;
        }
        //是否_是pc版
        boolean isPc = false;
        int method = 7;//支付类型 GameUtils.getPlayerPayType(player, version);
        ChargeItemTemplate chargetemalte1 = null;//购买商品信息---- ChargeItemTemplate.get(chargeid);
        if (version == 1) {
            if (isPc) {
                //微信二维码
                WxPayQr(player, chargetemalte1, time, channelCode);
                return;
            }
            if (method == 1) {
                //微信支付
                WxPay(player, chargetemalte1, time, channelCode);
            }
            if (method == 6 || method == 7) {
                //微信H5支付
                WxPayH5(player, chargetemalte1, time, channelCode);
            }
        } else {
            if (isPc) {
                //支付宝二维码
                AliPayNative(player, chargetemalte1, channelCode);
                return;
            }
            if (method == 1) {
                //支付宝app
                AliPay(player, chargetemalte1, channelCode);
            }
            if (method == 6 || method == 7) {
                //支付宝H5
                AliPayH5(player, chargetemalte1, channelCode);
            }

        }
    }

    public void WxPay(Player player, ChargeItemTemplate chargetemalte1, long time, String channelCode) {
        HashMap<String, Object> map = new HashMap<String, Object>();

        if (chargetemalte1 == null) {
//			SLog.info("ChargeTemplate is  null");
            return;
        }
        CLog.i(tag,"[WxPreorder]playerName[" + player.getName() + "]playerId[" + player.getId() + "]ChargeTemplate["
                + chargetemalte1.getChargeNum() + "]");
        map.put("appid", wx_appid);
        map.put("mchid", wx_mchid);
        map.put("description", chargetemalte1.getChargeNum() + "元充值");// 支付简单的描述
        map.put("out_trade_no", player.getId() + "_" + time);// 充值订单号
        //	map.put("total_fee", String.valueOf(chargetemalte1.getChargeNum() * 100));// 充值钱数 单位是分
        //	map.put("spbill_create_ip", session.getClientIP());// 充值账号ip
        map.put("attach", ConfigData.JETTY_SERVER_IP + "|" + ConfigData.JETTY_SERVER_PORT + "|" + ConfigData.SERVERID + "|" + ConfigData.GAMEVERSION + "|" + player.getAccountId() + "|" + player.getId() + "|"
                + chargetemalte1.getId() + "|" + player.getName() + "|" + player.getLevel() + "|" + player.getJob() + "|" + channelCode);// 透传参数
        map.put("notify_url", ConfigData.CHARGECALLURL + wx_notify_url);// 回调地址
        Map<String, Object> amount = new HashMap<String, Object>();

        amount.put("total", chargetemalte1.getChargeNum() * 100);

        map.put("amount", amount);
        JSON json = (JSON) JSONObject.toJSON(map);
        String result = HttpUtil.postWXJson(url, json.toJSONString(), "POST", wx_mchid, privatekey);
        CLog.i(tag,"[WX]result[" + result + "]");
        JSONObject respifno = JSONObject.parseObject(result);
        String prepay_id = respifno.getString("prepay_id");
        if (prepay_id == null) {
            player.sendError(145, "但是当时u的水");
            return;
        }
        RolePayResp resp = new RolePayResp(/* packet.getCCode() */);
        resp.orderInfo = prepay_id;
        resp.ret = 1;
        resp.send();

    }

    public void WxPayH5(Player player, ChargeItemTemplate chargetemalte1, long time, String channelCode) {
        HashMap<String, Object> map = new HashMap<String, Object>();

        if (chargetemalte1 == null) {
//			SLog.info("ChargeTemplate is  null");
            return;
        }
        CLog.i(tag,"[WxPreorder]playerName[" + player.getName() + "]playerId[" + player.getId() + "]ChargeTemplate["
                + chargetemalte1.getChargeNum() + "]");
        map.put("appid", wx_appid);
        map.put("mchid", wx_mchid);
        map.put("description", chargetemalte1.getChargeNum() + "元充值");
        map.put("out_trade_no", player.getId() + "_" + time);// 充值订单号
        map.put("attach", ConfigData.JETTY_SERVER_IP + "|" + ConfigData.JETTY_SERVER_PORT + "|" + ConfigData.SERVERID + "|" + ConfigData.GAMEVERSION + "|" + player.getAccountId() + "|" + player.getId() + "|"
                + chargetemalte1.getId() + "|" + player.getName() + "|" + player.getLevel() + "|" + player.getJob() + "|" + channelCode);// 透传参数
        map.put("notify_url", ConfigData.CHARGECALLURL + wx_notify_url);// 回调地址
        Map<String, Object> amount = new HashMap<String, Object>();
        amount.put("total", chargetemalte1.getChargeNum() * 100);
        map.put("amount", amount);
        Map<String, Object> scene_info = new HashMap<String, Object>();
        scene_info.put("payer_client_ip", player.getClientIP());
        Map<String, String> h5_info = new HashMap<String, String>();
        h5_info.put("type", "Wap");
        scene_info.put("h5_info", h5_info);
        map.put("scene_info", scene_info);

        JSON json = (JSON) JSON.toJSON(map);
        RolePayResp resp = new RolePayResp(/* packet.getCCode() */);
        resp.orderInfo = json.toJSONString();
        System.err.println(json.toJSONString());
        String s = json.toJSONString();
        String z = HttpUtil.postWXJson("https://api.mch.weixin.qq.com/v3/pay/transactions/h5", s, "POST", wx_mchid, privatekey);
        CLog.i(tag,"[微信H5]" + z);

        JSONObject zjson = JSONObject.parseObject(z);
        resp.ret = 1;
        //resp.orderInfo = zjson.getString("h5_url");
        resp.orderInfo = "http://pay.bjylhyu.com:9221/charge/charge.html?url=" + UrlEncoded.encodeString(zjson.getString("h5_url"));
        try {
            resp.prepayId = URLEncoder.encode("paydemo.bjylhyu.com", "UTF-8");
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        resp.send();

    }


    public void WxPayQr(Player player, ChargeItemTemplate chargetemalte1, long time, String channelCode) {
        HashMap<String, Object> map = new HashMap<String, Object>();

        if (chargetemalte1 == null) {
//			SLog.info("ChargeTemplate is  null");
            return;
        }
        CLog.i(tag,"[WxPreorder]playerName[" + player.getName() + "]playerId[" + player.getId() + "]ChargeTemplate["
                + chargetemalte1.getChargeNum() + "]");
        map.put("appid", wx_appid);
        map.put("mchid", wx_mchid);
        map.put("description", chargetemalte1.getChargeNum() + "元充值");
        map.put("out_trade_no", player.getId() + "_" + time);// 充值订单号
        map.put("attach", ConfigData.JETTY_SERVER_IP + "|" + ConfigData.JETTY_SERVER_PORT + "|" + ConfigData.SERVERID + "|" + ConfigData.GAMEVERSION + "|" + player.getAccountId() + "|" + player.getId() + "|"
                + chargetemalte1.getId() + "|" + player.getName() + "|" + player.getLevel() + "|" + player.getJob() + "|" + channelCode);// 透传参数
        map.put("notify_url", ConfigData.CHARGECALLURL + wx_notify_url);// 回调地址
        Map<String, Object> amount = new HashMap<String, Object>();
        amount.put("total", chargetemalte1.getChargeNum() * 100);
        map.put("amount", amount);
        Map<String, Object> scene_info = new HashMap<String, Object>();
        scene_info.put("payer_client_ip", player.getClientIP());
        map.put("scene_info", scene_info);

        JSON json = (JSON) JSON.toJSON(map);
        RolePayResp resp = new RolePayResp(/* packet.getCCode() */);
        resp.orderInfo = json.toJSONString();
        System.err.println(json.toJSONString());
        String s = json.toJSONString();
        String z = HttpUtil.postWXJson("https://api.mch.weixin.qq.com/v3/pay/transactions/native", s, "POST", wx_mchid, privatekey);
        CLog.i(tag,"[微信 二维码]" + z);
        JSONObject zjson = JSONObject.parseObject(z);
        resp.ret = 1;
        resp.orderInfo = zjson.getString("code_url");
        resp.send();

    }

    /**
     * 支付宝支付
     */
    public void AliPay(Player player, ChargeItemTemplate chargetemalte1, String channelCode) {
        long time = System.currentTimeMillis();
        String body = "火龙传奇充值_" + player.getName() + "_" + player.getLevel() + "_" + player.getJob() + "_" + channelCode;
        String subject = chargetemalte1.getChargeNum() + "元充值";

        String out_trade_no = player.getId() + "_" + time;// 订单号
        String timeout_express = "1d";
        String total_amount = chargetemalte1.getChargeNum() + ".00";// 订单总金额 单位元 精确到小数点后两位;
        Map<String, String> params = new HashMap<String, String>();
        params.put("app_id", zfb_appid);
        Map<String, Object> biz_contentmap = new HashMap<String, Object>();
        biz_contentmap.put("body", body);
        biz_contentmap.put("subject", subject);
        biz_contentmap.put("out_trade_no", out_trade_no);
        biz_contentmap.put("timeout_express", timeout_express);
        biz_contentmap.put("total_amount", total_amount);
        biz_contentmap.put("product_code", "QUICK_MSECURITY_PAY");
        biz_contentmap.put("passback_params", ConfigData.SERVERID + "|" + ConfigData.GAMEVERSION + "|" + player.getAccountId() + "|" + player.getId() + "|" + chargetemalte1.getId() + "|" + chargetemalte1.getChargeNum());
        params.put("method", zfb_method);
        params.put("charset", charset);
        params.put("sign_type", sign_type);
        params.put("timestamp", TimeUtil.timestampToFormatDate(time, "yyyy-MM-dd HH:mm:ss"));
        params.put("version", version);
        params.put("notify_url", ConfigData.CHARGECALLURL + notify_url);
        JSONObject jsonobject = new JSONObject(biz_contentmap);
        params.put("biz_content", jsonobject.toJSONString());
        String sign = "";

        try {
            sign = WxpayUtils.createSign(params, false);
            sign = RSA.signRsa2(sign, alikey, "UTF-8");
            params.put("sign", sign);

            String str = WxpayUtils.createSign(params, true);// 最终返回 串
            CLog.i(tag,"====支付宝str" + str);
            RolePayResp resp = new RolePayResp();
            resp.ret = 2;
            resp.orderInfo = str;
            resp.send();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    private String aliurl = "https://openapi.alipay.com/gateway.do";

    /**
     * 支付宝支付
     */
    public void AliPayH5(Player player, ChargeItemTemplate chargetemalte1, String channelCode) {
        long time = System.currentTimeMillis();
        String body = "火龙传奇充值_" + player.getName() + "_" + player.getLevel() + "_" + player.getJob() + "_" + channelCode;
        String subject = chargetemalte1.getChargeNum() + "元充值";

        String out_trade_no = player.getId() + "_" + time;// 订单号
        String timeout_express = "1d";
        String total_amount = chargetemalte1.getChargeNum() + ".00";// 订单总金额 单位元 精确到小数点后两位;
        Map<String, String> params = new HashMap<String, String>();
        params.put("app_id", zfb_appid);
        Map<String, Object> biz_contentmap = new HashMap<String, Object>();
        biz_contentmap.put("body", body);
        biz_contentmap.put("subject", subject);
        biz_contentmap.put("out_trade_no", out_trade_no);
        biz_contentmap.put("total_amount", total_amount);
        biz_contentmap.put("timeout_express", timeout_express);
        biz_contentmap.put("quit_url", "quit_url");
        biz_contentmap.put("product_code", "QUICK_WAP_WAY");
        biz_contentmap.put("passback_params", ConfigData.SERVERID + "|" + ConfigData.GAMEVERSION + "|" + player.getAccountId() + "|" + player.getId() + "|" + chargetemalte1.getId() + "|" + chargetemalte1.getChargeNum());
        biz_contentmap.put("goods_id", chargetemalte1.getId());
        biz_contentmap.put("goods_name", "礼包");
        biz_contentmap.put("price", chargetemalte1.getChargeNum());
        params.put("method", zfb_h5method);
        params.put("charset", charset);
        params.put("sign_type", sign_type);
        params.put("timestamp", TimeUtil.timestampToFormatDate(time, "yyyy-MM-dd HH:mm:ss"));
        params.put("version", version);
        params.put("notify_url", ConfigData.CHARGECALLURL + notify_url);
        JSONObject jsonobject = new JSONObject(biz_contentmap);
        params.put("biz_content", jsonobject.toJSONString());
        String sign = "";

        try {
            sign = WxpayUtils.createSign(params, false);
            sign = RSA.signRsa2(sign, alikey, "UTF-8");
            params.put("sign", sign);

            String str = WxpayUtils.createSign(params, true);// 最终返回 串
            CLog.i(tag,"[支付宝h5str]" + str);
            RolePayResp resp = new RolePayResp();
            resp.ret = 2;
            resp.orderInfo = aliurl + "?" + str;
            resp.send();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * 支付宝二维码
     */
    public void AliPayNative(Player player, ChargeItemTemplate chargetemalte1, String channelCode) {
        long time = System.currentTimeMillis();
        String body = player.getName() + "|" +
                player.getLevel() + "|" +
                player.getJob() + "|" +
                channelCode + "|" +
                ConfigData.SERVERID + "|" +
                ConfigData.GAMEVERSION + "|" +
                player.getAccountId() + "|" +
                player.getId() + "|" +
                chargetemalte1.getId();

        String subject = chargetemalte1.getChargeNum() + "元充值";

        String out_trade_no = player.getId() + "_" + time;// 订单号
        String timeout_express = "1d";
        String total_amount = chargetemalte1.getChargeNum() + ".00";// 订单总金额 单位元 精确到小数点后两位;
        Map<String, String> params = new HashMap<String, String>();
        params.put("app_id", zfb_appid);
        Map<String, Object> biz_contentmap = new HashMap<String, Object>();
        biz_contentmap.put("body", body);
        biz_contentmap.put("subject", subject);
        biz_contentmap.put("out_trade_no", out_trade_no);
        biz_contentmap.put("total_amount", total_amount);
        biz_contentmap.put("timeout_express", timeout_express);
        biz_contentmap.put("quit_url", "quit_url");
        biz_contentmap.put("product_code", "FACE_TO_FACE_PAYMENT");

        Map<String, Object>[] goods_details = new HashMap[1];
        Map<String, Object> goods_detail = new HashMap<String, Object>();
        goods_details[0] = goods_detail;
        goods_detail.put("goods_id", chargetemalte1.getId());
        goods_detail.put("goods_name", ConfigData.SERVERID + "|" + ConfigData.GAMEVERSION + "|" + player.getAccountId() + "|" + player.getId() + "|" + chargetemalte1.getId() + "|" + chargetemalte1.getChargeNum());
        goods_detail.put("price", chargetemalte1.getChargeNum());
        goods_detail.put("quantity", 1);
        biz_contentmap.put("goods_detail", goods_details);
        params.put("method", zfb_nativemethod);
        params.put("charset", charset);
        params.put("sign_type", sign_type);
        params.put("timestamp", TimeUtil.timestampToFormatDate(time, "yyyy-MM-dd HH:mm:ss"));
        params.put("version", version);
        params.put("notify_url", ConfigData.CHARGECALLURL + ali_notify_url);
        JSONObject jsonobject = new JSONObject(biz_contentmap);
        params.put("biz_content", jsonobject.toJSONString());
        String sign = "";

        try {
            sign = WxpayUtils.createSign(params, false);
            sign = RSA.signRsa2(sign, alikey, "UTF-8");
            params.put("sign", sign);

            String str = WxpayUtils.createSign(params, true);// 最终返回 串
            CLog.i(tag,"====支付宝h5str" + str);
            RolePayResp resp = new RolePayResp();
            resp.ret = 2;
            String result = HttpUtil.get(aliurl + "?" + str);
            CLog.i(tag,"[支付宝二维码返回]" + result + "");
            JSONObject respifno = JSONObject.parseObject(result);
            String qr_code = respifno.getString("alipay_trade_precreate_response");
            JSONObject respz = JSONObject.parseObject(qr_code);
            String qr_code1 = respz.getString("qr_code");
            CLog.i(tag,"qr_code1" + qr_code1);
            resp.orderInfo = qr_code1;
            resp.send();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    /**
     * @param player
     * @param chargetemalte1
     * @param channelCode
     */
    public String notify_chargeInfo(Player player, ChargeItemTemplate chargetemalte1, String channelCode, String method, String version) {
        StringBuffer info = new StringBuffer();

        info.append("model=" + method).append("&");

        info.append("playerName=" + player.getName()).append("&");

        info.append("playerId=" + player.getId()).append("&");

        info.append("Job=" + player.getJob()).append("&");

        info.append("channelCode=" + channelCode).append("&");

        info.append("version=" + version).append("&");

        info.append("ChargeNum=" + chargetemalte1.getChargeNum()).append("&");

        info.append("chargeId=" + chargetemalte1.getId() + "").append("&");

        info.append("lev=" + player.getLevel() + "").append("&");

        info.append("serverId=" + player.getServerId() + "").append("&");

        info.append("gameVersion=" + ConfigData.GAMEVERSION).append("&");
        ;

        info.append("accountId=" + player.getAccountId() + "").append("&");
        ;

        info.append("clientIp=" + player.getClientIP() + "");

        String rechargeinfo = HttpUtil.sendPosttext(ConfigData.CHARGECALLURL + "/chargeCall", info.toString());

        return rechargeinfo;

    }



    public static void main(String[] args) {
        System.err.println(UrlEncoded.encodeString("paydemo.bjylhyu.com/charge/ok.html"));
    }
}
